<template>
  <div class="category-filter">
    <div class="filter-tabs">
      <div
        v-for="category in categories"
        :key="category"
        :class="['filter-tab', { active: selectedCategory === category }]"
        @click="handleCategoryChange(category)"
      >
        {{ category }}
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters, mapActions } from 'vuex'

export default {
  name: 'ToolCategoryFilter',
  computed: {
    ...mapGetters('tools', ['getCategories', 'getSelectedCategory']),
    selectedCategory: {
      get() {
        return this.getSelectedCategory
      },
      set(value) {
        this.handleCategoryChange(value)
      }
    }
  },
  methods: {
    ...mapActions('tools', ['updateCategory']),
    handleCategoryChange(category) {
      this.updateCategory(category)
    }
  }
}
</script>

<style lang="scss" scoped>
.category-filter {
  margin-bottom: 24px;
  padding: 16px 0;
  border-bottom: 1px solid #e4e7ed;
  
  .filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    
    .filter-tab {
      padding: 8px 16px;
      border-radius: 16px;
      background-color: #f5f7fa;
      color: #606266;
      font-size: 14px;
      cursor: pointer;
      transition: all 0.3s ease;
      border: 1px solid transparent;
      
      &:hover {
        background-color: #e4e7ed;
        color: #303133;
      }
      
      &.active {
        background-color: #409EFF;
        color: #fff;
        border-color: #409EFF;
      }
    }
  }
}

@media (max-width: 768px) {
  .category-filter {
    .filter-tabs {
      justify-content: center;
      
      .filter-tab {
        font-size: 13px;
        padding: 6px 12px;
      }
    }
  }
}
</style> 